﻿using System.Collections.Generic;
using BlawkayEngine;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace BlawkayHockey
{
    public class Building
    {

        public Building(Game oGame, float oLengthZ, float oLengthX)
        {
            // Top
            Texture2D oTexture = oGame.Content.Load<Texture2D>("arenaFloor");
            _Quads = new List<Quad>();

            _Floor = new Quad(oGame, oTexture, null, Vector3.Zero, new Vector3(0, -1f, 0),
                VectorHelper.GLOBAL_UP, VectorHelper.GLOBAL_RIGHT, oLengthX, oLengthZ, false);
            _Quads.Add(_Floor);

            oTexture = oGame.Content.Load<Texture2D>("arenaWall");
            float oHeight = 700;
            _Walls = new List<Quad>();
            _Walls.Add(new Quad(oGame, oTexture, null, new Vector3(0, oHeight * 0.5f, -oLengthZ * 0.5f), Vector3.Zero, VectorHelper.GLOBAL_RIGHT, VectorHelper.GLOBAL_UP, oLengthX, oHeight, false));
            _Walls.Add(new Quad(oGame, oTexture, null, new Vector3(0, oHeight * 0.5f, oLengthZ * 0.5f), Vector3.Zero, -VectorHelper.GLOBAL_RIGHT, VectorHelper.GLOBAL_UP, oLengthX, oHeight, false));
            _Walls.Add(new Quad(oGame, oTexture, null, new Vector3(-oLengthX * 0.5f, oHeight * 0.5f, 0), Vector3.Zero, VectorHelper.GLOBAL_BACKWARD, VectorHelper.GLOBAL_UP, oLengthZ, oHeight, false));
            _Walls.Add(new Quad(oGame, oTexture, null, new Vector3(oLengthX * 0.5f, oHeight * 0.5f, 0), Vector3.Zero, VectorHelper.GLOBAL_BACKWARD, VectorHelper.GLOBAL_UP, oLengthZ, oHeight, false));

            foreach (Quad q in _Walls)
                _Quads.Add(q);
        }

        public void Update(Camera oCamera)
        {
            foreach (Quad q in _Quads)
                q.Update(oCamera);
        }

        public void DrawOpaque(Game oGame)
        {
            foreach (Quad q in _Quads)
                q.Draw(oGame);
        }


        List<Quad> _Quads;

        Quad _Floor;
        List<Quad> _Walls;
        Quad _Ceiling;
    }

}
